using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace DataPopulation
{
    enum ItemType
    {
        CreateResources,
        CreateProjects,
        CreateWinProj,
        CreateTasks,
        BuidTeam,
        CreateDependencies,
        CreateAssignments,
        PublishProjects
    }

    enum ItemStatus
    {
        Ready,
        Processing,
        Completed,
        Failed
    }

    class WorkQueues
    {
        static public CreateResourcesQueue qCreateResources = new CreateResourcesQueue();
        static public CreateProjectsQueue qCreateProjects = new CreateProjectsQueue();
        static public CreateWinProjQueue qCreateWinProj = new CreateWinProjQueue();
        static public CreateTasksQueue qCreateTasks = new CreateTasksQueue();
        static public CreateCFsQueue qCreateCFs = new CreateCFsQueue();
        static public CreateDependenciesQueue qCreateDependencies = new CreateDependenciesQueue();
        static public BuildTeamQueue qBuildTeam = new BuildTeamQueue();
        static public CreateAssignmentsQueue qCreateAssignments = new CreateAssignmentsQueue();
        static public PublishProjectsQueue qPublishProjects = new PublishProjectsQueue();
    }

    class WorkItem
    {
        public DateTime createdDate;
        public DateTime startProcessing;
        public DateTime endProcessing;
        public ItemStatus status;
        public string psURL;
        public int entityLimit;
        public string connectionString;
    }

    class CreateResourcesItem : WorkItem
    {
        public string resPrefix;
        public int start;
        public int end;
        public int numDigits;
        public bool createCFs;
        public bool leafsOnly;
        public bool ntAuth;
        public bool createLogins;
        public string domain;
        public string password;
        public ArrayList securityGroups;
        public ArrayList securityCategories;

        internal CreateResourcesItem()
        {
        }
    }

    class CreateProjectsItem : WorkItem
    {
        public string projectType;
        public string calendarType;
        public Guid template;
        public string projectPrefix;
        public int projectStart;
        public int projectEnd;
        public int projectNumDigits;
        public bool createCFs;
        public bool leafsOnly;
        public string ownerPrefix;
        public int ownerStart;
        public int ownerEnd;
        public int ownerNumDigits;

        internal CreateProjectsItem()
        {
        }
    }

    class CreateTasksItem : WorkItem
    {
        public int tasksPerProject;
        public string taskPrefix;
        public int numDigits;
        public int maxDuration;
        public int minDuration;
        public bool createCFs;
        public bool leafsOnly;
        public string projectPrefix;

        internal CreateTasksItem()
        {
        }
    }

    class CreateWinProjItem : WorkItem
    {
        public string projectPrefix;
        public int tasksPerProject;
        public string taskPrefix;
        public int numDigits;
        public int maxDuration;
        public int minDuration;
        public int maxDepDuration;
        public int minDepDuration;
        public int maxAssignments;
        public int minAssignments;
        public bool createTaskCFs;
        public bool taskLeafsOnly;

        internal CreateWinProjItem()
        {
        }
    }

    class CreateCFsItem : WorkItem
    {
        public string projectPrefix;
        public bool createProjectCFs;
        public bool createTaskCFs;
        public bool projectLeafsOnly;
        public bool taskLeafsOnly;
        public string resPrefix;
        public bool createResCFs;
        public bool resLeafsOnly;

        internal CreateCFsItem()
        {
        }
    }

    class CreateDependenciesItem : WorkItem
    {
        public string projectPrefix;
        public int maxDuration;
        public int minDuration;

        internal CreateDependenciesItem()
        {
        }
    }

    class BuildTeamItem : WorkItem
    {
        public string resPrefix;
        public int resTeamSize;
        public string projectPrefix;

        internal BuildTeamItem()
        {
        }
    }

    class CreateAssignmentsItem : WorkItem
    {
        public int maxAssignments;
        public int minAssignments;
        public string projectPrefix;

        internal CreateAssignmentsItem()
        {
        }
    }

    class PublishProjectsItem : WorkItem
    {
        public string projectPrefix;

        internal PublishProjectsItem()
        {
        }
    }

    class CreateResourcesQueue : Queue
    {
        public CreateResourcesItem NewItem()
        {
            return new CreateResourcesItem();
        }

        public void EnqueueItem(CreateResourcesItem item)
        {
            item.status = ItemStatus.Ready;
            item.createdDate = DateTime.Now;
            Enqueue(item);
        }

        public CreateResourcesItem PeekItem()
        {
            if (Count == 0) return null;
            return (CreateResourcesItem)Peek();
        }

        public CreateResourcesItem DequeueItem()
        {
            if (Count == 0) return null;
            return (CreateResourcesItem)Dequeue();
        }
    }

    class CreateProjectsQueue : Queue
    {
        public CreateProjectsItem NewItem()
        {
            return new CreateProjectsItem();
        }

        public void EnqueueItem(CreateProjectsItem item)
        {
            item.status = ItemStatus.Ready;
            item.createdDate = DateTime.Now;
            Enqueue(item);
        }

        public CreateProjectsItem PeekItem()
        {
            if (Count == 0) return null;
            return (CreateProjectsItem)Peek();
        }

        public CreateProjectsItem DequeueItem()
        {
            if (Count == 0) return null;
            return (CreateProjectsItem)Dequeue();
        }
    }

    class CreateWinProjQueue : Queue
    {
        public CreateWinProjItem NewItem()
        {
            return new CreateWinProjItem();
        }

        public void EnqueueItem(CreateWinProjItem item)
        {
            item.status = ItemStatus.Ready;
            item.createdDate = DateTime.Now;
            Enqueue(item);
        }

        public CreateWinProjItem PeekItem()
        {
            if (Count == 0) return null;
            return (CreateWinProjItem)Peek();
        }

        public CreateWinProjItem DequeueItem()
        {
            if (Count == 0) return null;
            return (CreateWinProjItem)Dequeue();
        }
    }

    class CreateTasksQueue : Queue
    {
        public CreateTasksItem NewItem()
        {
            return new CreateTasksItem();
        }

        public void EnqueueItem(CreateTasksItem item)
        {
            item.status = ItemStatus.Ready;
            item.createdDate = DateTime.Now;
            Enqueue(item);
        }

        public CreateTasksItem PeekItem()
        {
            if (Count == 0) return null;
            return (CreateTasksItem)Peek();
        }

        public CreateTasksItem DequeueItem()
        {
            if (Count == 0) return null;
            return (CreateTasksItem)Dequeue();
        }
    }

    class CreateCFsQueue : Queue
    {
        public CreateCFsItem NewItem()
        {
            return new CreateCFsItem();
        }

        public void EnqueueItem(CreateCFsItem item)
        {
            item.status = ItemStatus.Ready;
            item.createdDate = DateTime.Now;
            Enqueue(item);
        }

        public CreateCFsItem PeekItem()
        {
            if (Count == 0) return null;
            return (CreateCFsItem)Peek();
        }

        public CreateCFsItem DequeueItem()
        {
            if (Count == 0) return null;
            return (CreateCFsItem)Dequeue();
        }
    }

    class CreateDependenciesQueue : Queue
    {
        public CreateDependenciesItem NewItem()
        {
            return new CreateDependenciesItem();
        }

        public void EnqueueItem(CreateDependenciesItem item)
        {
            item.status = ItemStatus.Ready;
            item.createdDate = DateTime.Now;
            Enqueue(item);
        }

        public CreateDependenciesItem PeekItem()
        {
            if (Count == 0) return null;
            return (CreateDependenciesItem)Peek();
        }

        public CreateDependenciesItem DequeueItem()
        {
            if (Count == 0) return null;
            return (CreateDependenciesItem)Dequeue();
        }
    }

    class BuildTeamQueue : Queue
    {
        public BuildTeamItem NewItem()
        {
            return new BuildTeamItem();
        }

        public void EnqueueItem(BuildTeamItem item)
        {
            item.status = ItemStatus.Ready;
            item.createdDate = DateTime.Now;
            Enqueue(item);
        }

        public BuildTeamItem PeekItem()
        {
            if (Count == 0) return null;
            return (BuildTeamItem)Peek();
        }

        public BuildTeamItem DequeueItem()
        {
            if (Count == 0) return null;
            return (BuildTeamItem)Dequeue();
        }
    }

    class CreateAssignmentsQueue : Queue
    {
        public CreateAssignmentsItem NewItem()
        {
            return new CreateAssignmentsItem();
        }

        public void EnqueueItem(CreateAssignmentsItem item)
        {
            item.status = ItemStatus.Ready;
            item.createdDate = DateTime.Now;
            Enqueue(item);
        }

        public CreateAssignmentsItem PeekItem()
        {
            if (Count == 0) return null;
            return (CreateAssignmentsItem)Peek();
        }

        public CreateAssignmentsItem DequeueItem()
        {
            if (Count == 0) return null;
            return (CreateAssignmentsItem)Dequeue();
        }
    }

    class PublishProjectsQueue : Queue
    {
        public PublishProjectsItem NewItem()
        {
            return new PublishProjectsItem();
        }

        public void EnqueueItem(PublishProjectsItem item)
        {
            item.status = ItemStatus.Ready;
            item.createdDate = DateTime.Now;
            Enqueue(item);
        }

        public PublishProjectsItem PeekItem()
        {
            if (Count == 0) return null;
            return (PublishProjectsItem)Peek();
        }

        public PublishProjectsItem DequeueItem()
        {
            if (Count == 0) return null;
            return (PublishProjectsItem)Dequeue();
        }
    }
}
